Skip to content

feat(libSceHttp): add synchronous HTTP request transport - #9834

Draft
DoubleAAGuy wants to merge 17 commits into
boykopovar:mainfrom
DoubleAAGuy:feat/libscehttp-request-transport
Draft

DoubleAAGuy wants to merge 17 commits into
boykopovar:mainfrom
DoubleAAGuy:feat/libscehttp-request-transport

Conversation

@DoubleAAGuy

@DoubleAAGuy DoubleAAGuy commented Oct 22, 2026 •

Copy link
Copy Markdown

What

Implement a synchronous HTTP/1.1 request path in libSceHttp over the existing libSceNet and libSceSsl libraries. Connections and requests retain their URL/method and request headers; sceHttpSendRequest sends the request and parses response status/headers, while sceHttpReadData streams fixed-length, chunked, or connection-close bodies. Status, content length, response headers, TLS verification callbacks, DNS/connect/I/O timeouts, and automatic redirects are wired into this path. DNS lookups use a bounded process-lifetime worker pool so the configured resolve deadline bounds the caller even though libc getaddrinfo cannot be cancelled; late results are discarded. Connect timeouts use a nonblocking socket plus libSceNet epoll; cross-origin redirects drop caller-supplied Authorization, Proxy-Authorization, Cookie, and Host headers.

The concrete caller is Prospero Themes (PPSA90210): its StoreHttpClient loads libSceHttp and libSceSsl and uses GET/POST, request headers, TLS callbacks, response headers and body reads for its community store.

Nonblocking requests and epoll completion events, request-side chunked transfer, persistent connection reuse, gzip, cookies/authentication and proxy routing remain unsupported. TLS uses libSceSsl verification and the caller's verify callback, including PPSA90210's accept-certificate callback; other HTTP-specific TLS flags remain unimplemented.

Tested

AArch64 Linux host; focused x86-64 build and execution under QEMU user emulation:

  • Built the actual libc, libkernel, libSceNetCtl, libSceNet, libSceSsl, libSceHttp, and committed HTTP test targets using GCC 12.2.0 in an out-of-tree CMake harness.
  • Ran guest_http, guest_http_response_header, guest_http_options, guest_http_transport, and guest_http_transport_context_allocation under QEMU x86-64 emulation; all five passed. guest_http_transport includes fixed-length/chunked bodies, redirects with cross-origin credential stripping, deterministic DNS/connect timeout cases, and a TLS loopback exchange whose untrusted certificate is accepted through the supplied verification callback. The allocation test sweeps 16 one-shot failure budgets with and without an existing context, checks failed-context rollback and retry, and verifies failed IDs have neither pool stats nor transport templates.
  • python3 tools/check_conventions.py --base origin/main, syntax checks for changed sources/tests, and Request.cpp with -Wall -Wextra -Werror passed.

This was not a native x86-64 run or a full project build. The standard root CMake configuration is unavailable here because SDL lacks XRandR development support; the focused CMake harness bypassed the unrelated SDL build. No PS5 console test was available.

Overlap review

tools/pr_overlap.py --branch feat/libscehttp-request-transport --repo boykopovar/AnyPS5 could not run to completion because this host has Git 2.34.1 and the tool uses the newer git merge-tree --write-tree interface. I manually reviewed the overlapping work. #8357 has merged and is in the current base; this PR now registers its pool-size metadata transactionally with HTTP options and transport state. #9630 remains a dependency for the context/epoll allocation-safety changes. #8620 has been closed without title evidence; its cookie-limit changes are not included, so this PR owns the transport debt update. #9417, #9405 and #9413 have since merged and are in the current base; this PR does not modify their request-header-removal, auth-option or cookie-option behavior. #8541’s TLS test CMake hunk is no longer touched, and #9073’s author confirmed no exact hunk overlap after the UriCopy debt-line change. #6044’s test reorganization is handled by placing the new test in tests/networking; the uncomparable #8646 offline-import hunk does not change the assertion modified here.

Checklist

  • Based on current main; no other open PR implements the same request functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: fix(http): preserve context and epoll state on allocation failure #9630
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Progress report (b97867d → 6f0f98b)

📈 System libraries: 47.94% (+0.0025%, +1 implemented function)

✅ 1 implemented
Library Name
libSceHttp sceHttpAddRequestHeaderRaw

Changed libraries (implemented exports)

Library Before After Change
libSceHttp 113/123 (91.87%) 114/123 (92.68%) +0.81%

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 12056 core/libs/tests/GuestHttp.cpp
docs/dev/debt/libSceHttp.md
PR 20805 core/libs/tests/GuestHttp.cpp
docs/dev/debt/libSceHttp.md
PR 24528 core/libs/prx/libSceHttp/Export.cpp
core/libs/tests/GuestHttp.cpp

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking findings in the current draft:

  1. connectTimeOutUsec does not bound connection establishment. CreateSocketStream applies it as SO_SNDTIMEO, then calls sceNetConnect; the current libSceNet implementation uses blocking connect, and on Windows waits in select with no timeout. A peer that does not complete the handshake can therefore block indefinitely despite the configured connect timeout. Please implement a deadline-aware connect and test it, or explicitly leave this option unsupported and record that in the debt entry.

  2. Automatic redirects reuse request.requestHeaders unchanged after current changes. A cross-origin redirect (including HTTPS to HTTP) can forward caller-supplied Authorization or Cookie headers to the new server. Strip sensitive credentials when the origin changes, and add a redirect test that verifies they are not forwarded; ensure the Host header cannot remain pinned to the old origin either.

  3. The overlap report for this head flags a direct libSceSsl/CMakeLists.txt conflict with #8541 and a libSceHttp.md conflict with #9073. The body lists #9630, #8357 and #8620 but does not mention these overlaps. Please agree on sequencing with those authors and record the actual merge dependency/order in the checklist as CONTRIBUTING.md requires.

The current hosted run has conventions/intake/labels checks, but no build or test jobs. The PR reports syntax checks and temporary plain-HTTP loopback smoke tests; the committed guest_http_transport and TLS integration tests were source-checked but not run. Please run the committed focused transport tests on a supported host before marking the PR ready, including the TLS path.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking security issue in automatic redirects: PerformSend follows a Location to a newly parsed URL but reuses request.requestHeaders unchanged, and BuildRequest emits every retained header on each hop. A caller-supplied Authorization or other origin-scoped credential header is therefore sent to an unrelated host if the original server redirects there. The feature supports both automatic redirects and arbitrary request headers, so please strip sensitive headers when scheme/host/effective port changes (and add a loopback cross-origin redirect test proving the second server does not receive them). The existing relative redirect test does not cover this case.

The integration HTTP/TLS tests are reported source-checked but not executed locally; only native fixed/chunked smoke tests ran, with no TLS. CI product jobs are skipped. Also, the PR base is 0def01bc and current main is a6646f84 (44 commits ahead); please rebase after the redirect fix and rerun the committed transport tests on the final head. The declared dependencies on #9630, #8357, and #8620 are still open and are correctly listed.

@DoubleAAGuy

Copy link
Copy Markdown
Author

Addressed the two code findings in the new head: connect now switches the socket to nonblocking for sceNetConnect, waits on a writable sceNetEpoll with the configured microsecond deadline, checks SO_ERROR, then restores blocking mode; guest_http_transport adds a 100 ms timeout case. Redirects now strip Authorization, Proxy-Authorization, Cookie and caller Host when scheme/host/effective port changes; the redirect test crosses 127.0.0.1 to localhost and checks the second request. I moved the TLS integration into guest_http_transport, so #8541’s SSL CMake hunk is no longer in this diff. I also restored the debt line adjacent to #9073’s UriCopy change; this request path calls the existing sceHttpUriMerge. The body now lists #9630, #8357 and #8620 as dependencies. The Git 2.34 overlap-tool limitation remains; I manually reviewed those patches. I am keeping the PR in draft because this environment cannot run its committed HTTP/TLS CTest targets (Ninja unavailable; Makefile configure is blocked by SDL2/XRandR setup).

@DoubleAAGuy
DoubleAAGuy force-pushed the feat/libscehttp-request-transport branch from 549d1a7 to 9546f1f Compare October 22, 2026 18:50
@DoubleAAGuy

Copy link
Copy Markdown
Author

Rebased #9834 onto current main (a6fc8a4) and reran the convention check, C++ syntax checks for the changed sources/tests, Request.cpp with -Wall -Wextra -Werror, and the temporary fixed-length/chunked/connect-timeout smoke harnesses; all passed. The committed HTTP/TLS CTest targets still cannot be executed in this environment, so the PR remains draft and I am not claiming those tests passed.

The requested code fixes are in the current head: nonblocking connect plus epoll deadline and SO_ERROR check, and stripping Authorization/Proxy-Authorization/Cookie/Host on cross-origin redirects with a loopback test. On overlap sequencing: #8541 no longer conflicts because the TLS test moved into guest_http_transport; #9073’s author confirmed there is no exact hunk overlap after the debt-line change. The remaining declared dependencies are #9630 and #8357 for transactional context registration/teardown and #8620 for the shared Silent-stubs debt line. #8357’s author has agreed to sequence after #9630; #8620 has not replied to my ordering question yet. I manually checked the latest overlap report’s uncomparable #6044, #8646, #9822 and #9826 files; the test is placed under tests/networking, and the other shared files do not touch the same changed assertions/exports.

@DoubleAAGuy
DoubleAAGuy force-pushed the feat/libscehttp-request-transport branch from 9546f1f to 0eecfe5 Compare October 22, 2026 20:17
@DoubleAAGuy

Copy link
Copy Markdown
Author

The latest head is rebased on current main. The committed tests found and fixed two issues before this run: sceHttpUriMerge requires option 0 (the redirect path passed 0xff), and the existing guest_http test incorrectly treated live context id 1 as unknown after removing its earlier request creation.

I built the actual HTTP/network/SSL/kernel/libc targets and the committed tests with x86-64 GCC 12.2 in a focused out-of-tree CMake harness, then ran guest_http, guest_http_response_header, guest_http_options, and guest_http_transport under QEMU x86-64 emulation on this AArch64 host. All four pass, including the TLS, cross-origin redirect, and connect-timeout cases. This is not a native x86-64 run or the full project build; the focused harness bypasses the unrelated SDL/XRandR configuration. I’m keeping the PR draft because the native-host request remains outstanding and dependencies #9630, #8357, and #8620 are still open. @MarcZX10, would this focused emulated run be useful pending a native x86-64 run, or should I keep waiting for that validation?

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I re-reviewed the latest head 3381f7297ac4679fd49beab9467474e2b5f08320. The earlier redirect credential leak is addressed: authorization, proxy authorization, cookie, and host headers are removed when scheme, host, or effective port changes, and the author reports a cross-origin loopback test. The focused x86-64 build and QEMU test runs are also described with their limits. The current hosted product jobs (Linux, Windows, relinker, write-watch, and register-context) are skipped; conventions, eligibility, labels, and report pass. I did not run the transport tests locally. No additional actionable finding in this pass. I note the PR remains draft while its stated dependencies #9630, #8357, and #8620 are open and native x86-64 validation is outstanding.

@MarcZX10

Copy link
Copy Markdown
Contributor

I re-reviewed the latest head 3381f7297ac4679fd49beab9467474e2b5f08320. The earlier redirect credential leak is addressed: authorization, proxy authorization, cookie, and host headers are removed when scheme, host, or effective port changes, and the author reports a cross-origin loopback test. The focused x86-64 build and QEMU test runs are described with their limits. Current hosted product jobs (Linux, Windows, relinker, write-watch, and register-context) are skipped; conventions, eligibility, labels, and report pass. I did not run the transport tests locally. No additional actionable finding in this pass. The PR remains draft while its stated dependencies #9630, #8357, and #8620 are open and native x86-64 validation is outstanding.

@DoubleAAGuy
DoubleAAGuy force-pushed the feat/libscehttp-request-transport branch from 3381f72 to e43c472 Compare October 22, 2026 20:55
@DoubleAAGuy

Copy link
Copy Markdown
Author

Update: rebased the current PR head onto main at 9e568a38 and reran the focused x86-64 QEMU build/tests against that head. guest_http, guest_http_response_header, guest_http_options, and guest_http_transport all pass (4/4). The run remains emulated, not native x86-64; the PR stays draft pending the native-host validation and dependencies noted above.

@DoubleAAGuy
DoubleAAGuy force-pushed the feat/libscehttp-request-transport branch from e43c472 to f17e10b Compare October 23, 2026 04:29
@DoubleAAGuy

Copy link
Copy Markdown
Author

I added the concrete DNS-timeout behavior requested by the PPSA90210 client: sceHttpSetResolveTimeOut now bounds the HTTP caller's wait for host resolution. Resolution runs in a fixed four-worker host pool; because libc getaddrinfo cannot be cancelled, a timed-out job is abandoned and its eventual result discarded. guest_http_transport now injects a delayed resolver and verifies the configured deadline and resolver error path. The HTTP, response-header, options, and transport tests pass 4/4 under x86-64 QEMU emulation; native x86-64 is still outstanding. The branch is rebased on current main, passes conventions and Linux/MinGW source checks, and remains draft pending native validation and dependencies #9630, #8357, and #8620.

@DoubleAAGuy
DoubleAAGuy force-pushed the feat/libscehttp-request-transport branch from f17e10b to 3d67792 Compare October 23, 2026 04:30
@DoubleAAGuy

Copy link
Copy Markdown
Author

Further update to #9834: the request path now enforces PPSA90210's configured DNS resolve timeout with a bounded host-resolver worker pool; a delayed-resolver test checks the deadline and resolver error path. The TLS loopback test now leaves the test CA untrusted and verifies that the caller's accept-certificate callback is propagated and invoked, matching StoreHttpClient's setup. After these additions, the focused x86-64 GCC 12.2/QEMU run still passes all four tests: guest_http, guest_http_response_header, guest_http_options, and guest_http_transport. Conventions and Linux/MinGW syntax checks pass. Native x86-64 remains outstanding; this is still a draft pending that validation and the listed dependencies.

@DoubleAAGuy

Copy link
Copy Markdown
Author

Rebased #9834 onto current main (dd7a2c964) and reran conventions, Linux/MinGW syntax checks, and the focused x86-64 QEMU build/tests. All four tests pass on this head: guest_http, guest_http_response_header, guest_http_options, and guest_http_transport, including delayed DNS timeout and the TLS callback path. The native x86-64 limitation and dependencies remain unchanged, so the PR stays draft.

@kali113

kali113 commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

@MarcZX10 here is a console measurement of the unit of sceNetEpollWait's timeout, the question the review raises about Request.cpp. On a retail PS5 (firmware 13.590.001) the timeout is in microseconds.

A payload created a sceNetEpollCreate instance and added an idle UDP socket for EPOLLIN, so no event could arrive. It then timed each sceNetEpollWait(epoll, events, 4, timeout) call with CLOCK_MONOTONIC. Every call returned 0:

timeout time until it returned
0 13 us
1 122 us
500 586 us
1000 1050 us, 1147 us, 1119 us (3 calls)
100000 100140 us
1500000 1500148 us

Each wait lasted about the given number of microseconds plus about 0.1 ms. Main's sceNetEpollWait also reads the argument as microseconds (std::chrono::microseconds(timeout)), and the PR passes its microsecond value through unchanged. Negative timeouts were not measured.

AI-assisted: yes (Claude Code)

oneandonlydean and others added 5 commits December 3, 2026 21:26
From p3n1cillin's commit 16a8fb3 on boykopovar#11134.

Co-authored-by: p3nicillin <lcmcclellan12@gmail.com>
From p3n1cillin's commit f5dc38b on boykopovar#11134.

Co-authored-by: p3nicillin <lcmcclellan12@gmail.com>
…d check

From p3n1cillin's commit 191757d on boykopovar#11134.

Co-authored-by: p3nicillin <lcmcclellan12@gmail.com>
The chunk trailer bound, the public header exports and the offline-imports test fix are p3n1cillin's commits from boykopovar#11134.
…d module test

libSceHttp now links libSceNet and libSceSsl, and libSceNet needs
libSceNetCtl, so avplayer_http_patched_modules copies and patches all three.
@oneandonlydean

Copy link
Copy Markdown
Collaborator

@DoubleAAGuy I pushed onto this branch to finish the open review points: the chunk trailer section is now bounded, consumed input is dropped from the read buffer, and the transport exports use the public headers. Those three fixes are @p3n1cillin's commits from #11134, credited in each commit. I also merged main and staged libSceNet, libSceSsl and libSceNetCtl in avplayer_http_patched_modules, since libSceHttp now links them. The Linux build and the http, avplayer and public_headers tests pass locally. The PR is still a draft; mark it ready when you are happy with it, or say if you would like us to.

@coderabbitai

coderabbitai Bot commented Dec 3, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — no blocking findings

Nothing blocks this; the points below are optional.

What I ran

Reviewed head 6f0f98b3a5cfe2aec1cc3091ec8ea81e3b7c31e1 against main. I inspected the prepared diff and targeted source sections using shell tools and repo_read.py; no merged-preview check or build was run.

python3 repo_read.py cat core/libs/prx/libSceHttp/src/Request.cpp 321 356
python3 repo_read.py cat core/libs/prx/libSceHttp/src/Resolver.cpp 39 85
rg -n '^diff --git|^@@' diff.patch

Results

Check Result Note
Source review passed Targeted changed code inspected
Build and runtime checks not run No compilation or tests run
Negative control not run No test change or execution

Findings

Blocking

None.

Non-blocking

  • core/libs/prx/libSceHttp/src/Resolver.cpp:64-65 adds every lookup to an unbounded queue. If concurrent calls accumulate while resolver workers are occupied in getaddrinfo, queued jobs retain their host and service strings even after callers time out. Consider bounding the queue or rejecting excess work.

Sources

Not verified

No build, tests, native x86-64 run, or PS5 console behavior was verified. The focused test runs described by the author were not run during this review. The manifest lists no excluded files. Reviewed changed paths: core/libs/prx/libSceAvPlayer/CMakeLists.txt, core/libs/prx/libSceHttp/CMakeLists.txt, core/libs/prx/libSceHttp/Export.cpp, core/libs/prx/libSceHttp/src/Request.cpp, core/libs/prx/libSceHttp/src/Request.hpp, core/libs/prx/libSceHttp/src/Resolver.cpp, core/libs/prx/libSceHttp/src/Resolver.hpp, core/libs/tests/AvPlayerHttpModules.cmake, core/libs/tests/GuestHttp.cpp, core/libs/tests/GuestOfflineImports.cpp, core/libs/tests/HttpTransportContextAllocation.cpp, core/libs/tests/networking/GuestHttpTransport.cpp, and docs/dev/debt/libSceHttp.md.

To get this to a good state

Nothing is required.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build docs needs rebase Conflicts with main, rebase needed prx

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants